package com.wumeng.interview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wumeng.interview.R;
import com.wumeng.interview.bean.RecordBean;

import java.util.List;

/**
 * @Time : 2021/8/7
 * @Author : Wu-Meng
 * @Description :
 */
public class FirstRecyclerAdapter extends RecyclerView.Adapter<FirstRecyclerAdapter.ViewHolder>{

    private Context mContext;

    public List<List<RecordBean>> recordBeanListList;

    public FirstRecyclerAdapter(Context mContext, List<List<RecordBean>> recordBeanListList) {
        this.mContext = mContext;
        this.recordBeanListList = recordBeanListList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_item_first_recycler_view,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        List<RecordBean> recordBeanList = recordBeanListList.get(position);
        holder.recyclerView.setAdapter(new SecondRecyclerAdapter(recordBeanList));
    }

    @Override
    public int getItemCount() {
        return recordBeanListList != null ? recordBeanListList.size() : 0;
    }

    static class ViewHolder extends RecyclerView.ViewHolder  {

        private final RecyclerView recyclerView;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            recyclerView = itemView.findViewById(R.id.item_recycler);
            LinearLayoutManager manager = new LinearLayoutManager(itemView.getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            recyclerView.setLayoutManager(manager);
        }
    }

}
